package com.sgb.kjwl.view.ui.adapter.transport;

import android.content.Context;
import android.graphics.Paint;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.R;
import com.sgb.kjwl.view.ui.adapter.YoungBaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import org.jetbrains.annotations.Nullable;

import java.util.List;

public class FindMapTabAdapter extends YoungBaseRecycleAdapter<String> {
    private int selectIndex;

    public FindMapTabAdapter(Context context, @Nullable List<String> data) {
        super(context, R.layout.item_cargo_manage_home_tab, data);
    }

    @Override
    public void convert(ItemViewHolder helper, String item) {
        TextView tab = helper.getView(R.id.tv_tab_name);
        View line = helper.getView(R.id.v_tab_line);
        //
        tab.setText(item);
        //
        if (helper.getLayoutPosition() == selectIndex) {
            tab.setTextSize(16);
            tab.getPaint().setFlags(Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
            line.setVisibility(View.VISIBLE);
        } else {
            tab.setTextSize(15);
            tab.getPaint().setFlags(Paint.ANTI_ALIAS_FLAG);
            line.setVisibility(View.INVISIBLE);
        }
    }

    public void setSelectIndex(int selectIndex) {
        this.selectIndex = selectIndex;
        notifyDataSetChanged();
    }
}
